﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using TiTi.tea.DAL;
using TiTi.tea.Model;
using TiTi.tea.Dto;

namespace TiTi.tea.BLL
{
    public class UserCouponBLL
    {
        private UserCouponDAL dal = new UserCouponDAL();

        /// <summary>
        /// 获取用户优惠卷
        /// </summary>
        /// <param name="amount"></param>
        /// <returns></returns>
        public IEnumerable<UserCoupon> GetByUser(int userId)
        {
            return dal.GetAll(o => o.Status == 1 && o.UserId==userId);
        }

        /// <summary>
        /// 修改状态
        /// </summary>
        /// <param name="id"></param>
        /// <param name="status"></param>
        /// <returns></returns>
        public bool Update(int id,int status)
        {
            var entity = Get(id);
            entity.Status = status;
            return dal.Update(entity);
        }

        public UserCoupon Get(int id)
        {
            return dal.GetOne(o => o.Id == id);
        }
    }
}
